package com.techchat.backend.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 将项目根目录下的 "uploads/" 文件夹映射为 URL 路径 "/avatars/**" (已有)
        registry
                .addResourceHandler("/avatars/**")
                .addResourceLocations("file:uploads/");

        // 新增: 将项目根目录下的 "chat-uploads/" 文件夹映射为 URL 路径 "/chat-images/**"
        registry
                .addResourceHandler("/chat-images/**")
                .addResourceLocations("file:chat-uploads/");
    }
}
